package sum.CityForeignMarriages;

import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.FloatWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class SumCityFoMarriagesReducer extends Reducer<SumCityFoMarriagesBean, FloatWritable,SumCityFoMarriagesBean, FloatWritable> {
    FloatWritable outValue = new FloatWritable();

    @Override
    protected void reduce(SumCityFoMarriagesBean key, Iterable<FloatWritable> values, Context context) throws IOException, InterruptedException {
        float totalFoMarriages = 0;
        for (FloatWritable value : values){
            totalFoMarriages += value.get();
        }
        outValue.set(totalFoMarriages);
        context.write(key,outValue);
    }
}
